package com.tzw.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tzw.pojo.BasicKhal;
import com.tzw.pojo.BasicNews;
import com.tzw.pojo.ModuleOfProduct;
import com.tzw.service.BasicKhalService;
import com.tzw.service.BasicNewsService;
import com.tzw.service.ModuleOfProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 首页接口
 * */
@Controller
public class HomePageController {
    @Autowired
    private ModuleOfProductService moduleOfProductService;
    @Autowired
    private BasicKhalService basicKhalService;
    @Autowired
    private BasicNewsService basicNewsService;

    @GetMapping("/")
    public String indexView(Model model){
        List<ModuleOfProduct> productList = moduleOfProductService.list();
        QueryWrapper<BasicKhal> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("target","1");
        List<BasicKhal> khalList = basicKhalService.list(queryWrapper);
        List<BasicNews> newsList = basicNewsService.NewLimitsTen();
        model.addAttribute("prdList",productList);
        model.addAttribute("clientList",khalList);
        model.addAttribute("newList",newsList);
        return "/index";
    }


}
